<project name="rabbit" default="dist.bin" basedir=".">
    <description>
        Ant build file for RabbIT/4
    </description>

    <property name="major_version" value="4"/>
    <property name="minor_version" value="9"/>

    <!-- paths -->
    <property name="src" location="src"/>
    <property name="build" location="classes"/>
    <property name="dist" location="dist/${ant.project.name}${major_version}.${minor_version}"/>

    <!-- whether to compile with debug symbols -->
    <property name="debug_symbols" value="true"/>

    <!-- ________________________ DO NOT CHANGE ANYTHING BELOW ________________________ -->

    <path id="project.classpath">
      <fileset dir="libs">
        <include name="**/*.jar"/>
      </fileset>
    </path>

    <pathconvert property="mf.classpath" pathsep=" ">
      <path refid="project.classpath"/>
      <chainedmapper>
	<flattenmapper/>
	<globmapper from="*" to="../libs/*"/>
      </chainedmapper>
    </pathconvert>

    <target name="init">
        <!-- Create the build directory structure used by compile -->
        <mkdir dir="${build}"/>
    </target>

    <target name="compile" depends="init" description="compile the source">
        <!-- Compile the java code from ${src} into ${build} -->
        <javac
                srcdir="${src}"
                destdir="${build}"
                debug="${debug_symbols}"
                classpathref="project.classpath"
                deprecation="on"
                target="1.6"
                encoding="ISO-8859-1"
        />
    </target>

    <target name="dist.bin" depends="compile" description="generate the binary distribution">
        <mkdir dir="${dist}/jars"/>
        <copy todir="${build}">
            <fileset file="Help.txt"/>
               <fileset file="src/*.js"/>
        </copy>

        <jar jarfile="${dist}/jars/rabbit${major_version}.jar" basedir="${build}">
          <manifest>
            <attribute name="Main-Class" value="rabbit.proxy.ProxyStarter"/>
	    <attribute name="Class-Path" value="${mf.classpath}" />
          </manifest>
	</jar>



        <copy todir="${dist}/conf">
            <fileset dir="conf"/>
        </copy>

        <copy todir="${dist}/libs">
            <fileset dir="libs"/>
        </copy>

        <mkdir dir="${dist}/logs" />

        <copy todir="${dist}/htdocs">
            <fileset dir="htdocs"/>
        </copy>

        <copy todir="${dist}">
            <fileset file="ChangeLog"/>
            <fileset file="LICENSE"/>
            <fileset file="README"/>
        </copy>
    </target>

    <target name="clean" description="clean up build and dist">
        <delete dir="${build}"/>
        <delete dir="${dist}"/>
    </target>
</project>
